package edu.nf.vrs.reservation.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @author Lv
 * @date 2022/3/30
 * 本地缓存配置类
 */
@Configuration
public class CaffeineConfig {

    @Bean
    public Cache<String,Integer> caffeineCache(){
        return Caffeine.newBuilder()
                .expireAfterWrite(5, TimeUnit.SECONDS)
                //初始化缓存大小
                .initialCapacity(20)
                //是指缓存最大容量
                .maximumSize(500)
                .build();
    }
}
